import http from "@/axios";

/**
 * 登录
 */
export function login(user) {
  return http({
    url: "/login",
    method: "post",
    data: user,
  });
}

/**
 * 注册
 */
export function register(user) {
  return http({
    url: "/register",
    method: "post",
    data: user,
  });
}
/**
 * 重置密码
 */
export function resetPassword(resetPassword) {
  return http({
    url: "/password/reset",
    method: "post",
    data: resetPassword,
  });
}
/**
 * 上传文件
 */
export function uploadFile(file) {
  return http({
    url: "/oss/upload",
    method: "post",
    data: file,
  });
}
/**
 * 修改个人信息
 */
export function updateUserInfo(userInfo) {
  return http({
    url: "/update",
    method: "post",
    data: userInfo,
  });
}
/**
 * 查询用户信息
 */
export function userInfo() {
  return http({
    url: "/user/info",
    method: "get",
  });
}
/**
 * 校验注册邮箱是否可以注册
 */
export function checkEmail(email) {
  return http({
    url: "/check/email",
    method: "get",
    params: email,
  });
}

/**
 * 获取验证码
 */
export function postCode(email) {
  return http({
    url: "/code",
    method: "post",
    data: email,
    headers: {
      "Content-Type": "text/plain",
    },
  });
}

/**
 * 查询当前用户的收货地址列表
 */
export function receiveGoodsInfoList(params) {
  return http({
    url: "/receivegoodsinfo/list",
    method: "get",
    params: params,
  });
}

/**
 * 添加收货地址
 */
export function saveReceiveGoodsInfo(receiveGoodsInfo) {
  return http({
    url: "/receivegoodsinfo/save",
    method: "post",
    data: receiveGoodsInfo,
  });
}

/**
 * 修改收货地址
 */
export function updateReceiveGoodsInfo(receiveGoodsInfo) {
  return http({
    url: "/receivegoodsinfo/update",
    method: "post",
    data: receiveGoodsInfo,
  });
}

/**
 * 删除收货地址
 */
export function removeReceiveGoodsInfo(serialNos) {
  return http({
    url: "/receivegoodsinfo/delete",
    method: "delete",
    data: serialNos,
  });
}
/**
 * 获取收藏信息
 */
export function collectionInfoList(params) {
  return http({
    url: "/collection/list",
    method: "get",
    params: params,
  });
}
/**
 * 添加到收藏信息
 */
export function saveCollectionInfo(collectionInfo) {
  return http({
    url: "/collection/save",
    method: "post",
    data: collectionInfo,
  });
}
/**
 * 置顶收藏
 */
export function setTopCollectionInfo(serialNo) {
  return http({
    url: `/collection/top/${serialNo}`,
    method: "post",
  });
}
/**
 * 取消置顶收藏
 */
export function backTopCollectionInfo(serialNo) {
  return http({
    url: `/collection/down/${serialNo}`,
    method: "post",
  });
}
/**
 * 取消收藏商品
 */
export function removeCollectionInfo(serialNos) {
  return http({
    url: "/collection/delete",
    method: "delete",
    data: serialNos,
  });
}
/**
 * 获取购物车列表
 */
export function cartInfoList(params) {
  return http({
    url: "/cart/list",
    method: "get",
    params: params,
  });
}
/**
 * 加入购物车
 */
export function saveCartInfo(cartInfo) {
  return http({
    url: "/cart/save",
    method: "post",
    data: cartInfo,
  });
}
/**
 * 移除购物车某个内容
 */
export function removeCartInfo(serialNos) {
  return http({
    url: "/cart/delete",
    method: "delete",
    data: serialNos,
  });
}
/**
 * 获取我的订单信息
 */
export function orderInfoList(orderNo) {
  return http({
    url: "/order/list",
    method: "get",
  });
}
/**
 * 保存我的订单
 */
export function saveOrderInfo(orderInfo) {
  return http({
    url: "/order/save",
    method: "post",
    data: orderInfo,
  });
}
/**
 * 删除我的订单
 */
export function removeOrderInfo(serialNo) {
  return http({
    url: "/order/delete",
    method: "delete",
    data: serialNo,
  });
}
/**
 * 支付我的订单
 */
export function payOrderInfo(serialNo) {
  return http({
    url: "/order/pay",
    method: "post",
    data: serialNo,
  });
}
/**
 * 确认收货
 */
export function confirmReceiveGoods(serialNo) {
  return http({
    url: "/order/receive/goods",
    method: "post",
    data: serialNo,
  });
}
/**
 * 提交评价信息
 */
export function saveEvaluateInfo(evaluateList, serialNo) {
  return http({
    url: `/evaluation/save/${serialNo}`,
    method: "post",
    data: evaluateList,
  });
}
/**
 * 更新评价信息
 */
export function updataEvaluateInfo(evaluateInfo) {
  return http({
    url: "/evaluation/update",
    method: "post",
    data: evaluateInfo,
  });
}
/**
 * 删除评价信息
 */
export function removeEvaluateInfo(serialNo) {
  return http({
    url: "/evaluation/delete",
    method: "delete",
    data: serialNo,
  });
}
